package com.bear.cli;

import com.bear.cli.command.ConfigCommand;
import com.bear.cli.command.GenerateCommand;
import com.bear.cli.command.ListCommand;
import picocli.CommandLine;
import picocli.CommandLine.Command;

/**
 * @Author : bear
 * Description :这个类相当于命令模式中的遥控器，和一些功能进行绑定
 * @Create : 2024/11/12 - 19:35
 */
@Command(name = "bear",mixinStandardHelpOptions = true)
    public class CommandExecutor implements Runnable{

    private final CommandLine commandLine;

    {
        //与具体的功能进行绑定
        commandLine = new CommandLine(this)
                .addSubcommand(new GenerateCommand())
                .addSubcommand(new ConfigCommand())
                .addSubcommand(new ListCommand());
    }
@Override
    public void run() {
        //不输入子命令时给出友好提示
        System.out.println("请输入具体命令，或者 --help查看命令提示");
    }
    /**
     * 执行命令
     */
    public Integer doExecute(String[] args){
        return commandLine.execute(args);
    }
}
